#include <stdio.h>

int add(int a,int b)
{
	return a + b;
}
int sub(int a, int b)
{
	return a - b;
}
int mul(int a, int b)
{
	return a * b;
}
int div(int a, int b)
{
	return a / b;
}

int(*getcalc(char c))(int,int)
{
	if (c == '+')
	{
		return add;
	}
	else if (c == '-')
	{
		return sub;
	}
	else if (c == '*')
	{
		return mul;
	}
	else if (c == '/')
	{
		return div;
	}
	else
	{
		return NULL;
	}
}

int calculator(int a, int b, char c)
{
	getcalc(c)(a,b);
}

int calculator1(int a, int b, char c)
{
	int(*calc)(int, int);
	calc=getcalc(c);
	return calc(a, b);
}

int main()
{
	printf("%d\n", calculator1(2, 1, '+'));
	printf("%d\n", calculator1(2, 1, '-'));
	printf("%d\n", calculator1(2, 1, '*'));
	printf("%d\n", calculator1(2, 1, '/'));
	return 0;
}